#ifndef _TFTBASE_H
#define _TFTBASE_H

#ifdef __cplusplus
extern "C"
{
#endif
#include "stdint.h"
#include "Device/delay/delay.h"

// 画笔颜色
#define WHITE 0xFFFF
#define BLACK 0x0000
#define BLUE 0x001F
#define BRED 0XF81F
#define GRED 0XFFE0
#define GBLUE 0X07FF
#define RED 0xF800
#define MAGENTA 0xF81F
#define GREEN 0x07E0
#define CYAN 0x7FFF
#define YELLOW 0xFFE0
#define BROWN 0XBC40      // 棕色
#define BRRED 0XFC07      // 棕红色
#define GRAY 0X8430       // 灰色
#define DARKBLUE 0X01CF   // 深蓝色
#define LIGHTBLUE 0X7D7C  // 浅蓝色
#define GRAYBLUE 0X5458   // 灰蓝色
#define LIGHTGREEN 0X841F // 浅绿色
#define LGRAY 0XC618      // 浅灰色(PANNEL),窗体背景色
#define LGRAYBLUE 0XA651  // 浅灰蓝色(中间层颜色)
#define LBBLUE 0X2B12     // 浅棕蓝色(选择条目的反色)

#ifdef __cplusplus
}
#endif

class TFT
{
private:
    uint8_t USE_HORIZONTAL = 0; // 设置横屏或者竖屏显示 0或1为竖屏 2或3为横屏
    uint16_t width;
    uint16_t height;

public:

    TFT(uint8_t _dir,uint16_t _width,uint16_t _height):USE_HORIZONTAL(_dir),width(_width),height(_height){};

    virtual void LCD_RES_Clr() = 0;
    virtual void LCD_RES_Set() = 0;
    virtual void LCD_DC_Clr() = 0;
    virtual void LCD_DC_Set() = 0;
    virtual void LCD_CS_Clr() = 0;
    virtual void LCD_CS_Set() = 0;
    //virtual void LCD_BLK_Clr() = 0;
    //virtual void LCD_BLK_Set() = 0;
    virtual void LCD_Writ_Bus(uint8_t dat) = 0;
    virtual void LCD_WR_DATA(uint16_t dat) = 0;

    void LCD_GPIO_Init(void);
    void LCD_WR_DATA8(uint8_t dat);
    void LCD_WR_REG(uint8_t dat);
    void LCD_Address_Set(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2);

    void LCD_Fill(uint16_t xsta,uint16_t ysta,uint16_t xend,uint16_t yend,uint16_t color);//指定区域填充颜色
    void LCD_DrawPoint(uint16_t x,uint16_t y,uint16_t color);
    void LCD_DrawLine(uint16_t x1,uint16_t y1,uint16_t x2,uint16_t y2,uint16_t color);//在指定位置画一条线
    void LCD_ShowPicture(uint16_t x,uint16_t y,uint16_t length,uint16_t width,const uint8_t pic[]);
    void tft180_show_gray_image (uint16_t x, uint16_t y, const uint8_t *image, uint16_t width, uint16_t height, uint16_t dis_width, uint16_t dis_height, uint8_t threshold);
    void LCD_Init(void);
};

#endif
